<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
   <%@page import="it.polimi.travelDream.ejb.servlet.*" %>
   <%@page import="it.polimi.travelDream.entities.Package" %>
   <%@page import="it.polimi.travelDream.entities.*" %>
  <jsp:useBean id="pmgr" class="it.polimi.travelDream.ejb.beans.PackageMgr" scope="session" />
    <jsp:useBean id="tmgr" class="it.polimi.travelDream.ejb.beans.TransportationMgr" scope="session" />
    
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>
		  	TravelDreamLogin
		</title>
		<link rel="stylesheet" type="text/css" href="style.css" />
  	</head>
  
  <body>
  	<div class="header">
  		<ul>
	  		<li>TravelDream</li>
		    Package Personalization
	    </ul>
  	</div>
  	
  	<div class="section">
  	 
	    <div class="nav">
	    	<ul>
	    		<li> <a href="UHome.jsp">Home</a></li>
	    		<li> <a href="USearch.jsp">Search packages</a></li>
	    			<% if (request.getSession().getAttribute("utente")!=null )
		    	{ User z=(User)request.getSession().getAttribute("utente");
		    	out.println("<li><a href=/TravelDreamSystemWeb/ShowTravelList?travellistowner="+z.getId()+" >Travel List </a></li>"); 
		    	} %>
	    			 
	    			    		<% if (request.getSession().getAttribute("utente")!=null )
		    	{ User z=(User)request.getSession().getAttribute("utente");
		    	out.println("<li><a href=/TravelDreamSystemWeb/ShowWishList?wishlistowner="+z.getId()+" >Wish List </a></li>"); 
		    	} %>
	    		<li> <a href="UCart.jsp">Cart</a></li>
	    		<li><a href="/SendMail.jsp">Invite To WishList</a></li>
	    			<li> <a href="/TravelDreamSystemWeb/LogoutServlet?session=0"> Logout </a></li>
	    	</ul>
	    </div>
	    
	    <div class="content">
	    <% 
	      if (request.getSession().getAttribute("utente")!=null )
		    	{ User u=(User)request.getSession().getAttribute("utente");
		    		System.out.println("ciao"+u.getId());
		    	
	    
		    		%>
	    <%  
	  	int id = Integer.parseInt(request.getParameter("idPackage"));
	  	
	     %>
	    
	    <div class="guidetitle"> PLEASE CHOOSE A DEPARTURE </div>
	  	
	  	
	  				        <div class=record>
        			
	        			<div class=recordfield>
	        				Type
	        			</div>
	        			
	        			<div class=recordfield>
	        				Dep. 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Arr.
	        			</div>
	        		
	        			
	        			<div class=recordfield>
	        				Dep.Time 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Arr.Time 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Cost
	        			</div>
	        			
	        			<div class=recordfield>
	        				 
	        			</div>
	        			
	        		    <div class=recordfield>
	        				 
	        			</div>
        						    	
	    			</div>
	  	
	  	
	  	<%  
	  	Package pack = pmgr.getPackage(id);	  	
        		int i = pack.getTransportation().size() - 1;

    		
	  	       	while (i>=0) {
        			out.println("<div class=record>") ;
        			out.println("<form action=UPackagePersonalize2.jsp method=POST>") ;
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getid()+" name=type />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getDepartureFrom()+" name=from />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getGoingTo()+" name=to />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getOutBound()+" name=in />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getInBound()+ " name=out />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=fakeinput readonly=readonly type=text value="+pack.getTransportation().get(i).getCost()+ " name=cost  />");
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			
        			out.println("<input type=hidden value="+pack.getID()+" name=idPackage />");
        			out.println("<input type=hidden value="+pack.getTransportation().get(i).getid()+" name=idDeparture />");
        			out.println("<input class=smallbutton type=submit value=Next />");
        			out.println("</div>") ;
        			out.println("</form>") ;
        			
        			out.println("</div>");
        			i--;
	    			
        		}
	  	
	  	        		%>
    			   <% 
	    	if (request.getAttribute("message") == null) 
		    	{ 
		    		%>
						<div></div>
					<% 
				} 
	    	else 
		    	{ 
		    		%>
						<div class="advice"><%=request.getAttribute("message")%></div>
					<% 
				} 
		%>
		</div><%
		} else { 
				response.sendRedirect("/TravelDreamSystemWeb/login.jsp");
				%>
				
				
					<%
				}
		%>
    </div>
    
    <div class="footer">
    	<ul>
	    	<li>TravelDream Company srl © All rights reserved</li>
		    <li>Terms of use | Contacts | Team </li>
	    </ul>
    </div>
    
  </body>
</html>